package com.fly.springbootTemplate.controller;

import com.fly.springbootTemplate.entity.Student;
import com.fly.springbootTemplate.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;
    @RequestMapping("/addStudent")
    public boolean addStudent(Student student) {
        return studentService.addStudent(student);
    }
    @RequestMapping("/deleteStudent")
    public boolean deleteStudent(Integer sno) {
        return studentService.deleteStudent(sno);
    }
    @RequestMapping("/updateStudent")
    public boolean updateStudent(Student student) {
        return studentService.updateStudent(student);
    }
    @RequestMapping("/getAllStudent")
    public List<Student> getAllStudent() {
        return studentService.getAllStudent();
    }
    @RequestMapping("/getStudentBySno")
    public Student getStudentBySno(Integer sno) {
        return studentService.getStudentBySno(sno);
    }
    @RequestMapping("/updateStudentByItem")
    public boolean updateStudentByItem(Student student) {
        return studentService.updateStudentByItem(student);
    }
    @RequestMapping("addBatchStudent")
    public boolean addBatchStudent(@RequestBody  List<Student> students) {
        return studentService.addBatchStudent(students);
    }
    @RequestMapping("updateBatchStudent")
    public boolean updateBatchStudent(@RequestBody  List<Student> students) {
        return studentService.updateBatchStudent(students);
    }
}
